<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

if (isset($_COOKIE['user'])) {

    $row = R::getAll('SELECT * from usuarios where id = :id', [':id' => $_COOKIE['user']]);
    $_SESSION['user'] = $row[0];
}
?>




    <body>

        <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.php">The Pengüins Mafia</a>
                </div>
                <div class="navbar-collapse collapse">

                    <?php
                    if (isset($_SESSION['user'])) {
                        echo "<p class='navbar-text'>" . $_SESSION['user']['usuario'] . "</p>";
                        if ($_SESSION['user']['permisos'] == 'admin') {
                            echo "<button type='button' class='btn btn-info navbar-btn' onclick=\"window.location.href='adminraid.php'\">Raids</button>&nbsp &nbsp";
                        }
                        echo "<button type='button' class='btn btn-warning navbar-btn' onclick=\"window.location.href='pj.php'\">Personajes</button>&nbsp &nbsp";
                        echo "<button type='button' class='btn btn-danger navbar-btn' onclick=\"window.location.href='logout.php'\">Desloguear</button>";
                    } else {
                        ?>
                        <form class="navbar-form " role="form" method="POST" action="login.php">
                            <div class="form-group">
                                <input type="text" placeholder="Email" class="form-control" name="Email" required>
                            </div>
                            <div class="form-group">
                                <input type="password" placeholder="Password" class="form-control" name="Password" required>
                            </div>
                            <div class="btn-group"> <button type="submit" class="btn btn-success">Entrar</button><button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
                                    <span class="sr-only">Toggle Dropdown</span>
                                </button>
                                <ul class="dropdown-menu" role="menu">
                                    <li><a href="registrar.php">Registrarse</a></li>
                                </ul></div>
                        </form>
                    <?php } ?>
                </div><!--/.navbar-collapse -->
            </div>
        </div>